package top.lingchen.spring5.aopanno;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

/**
 * @Author 凌宸
 * @create 2021-11-30 上午 12:25
 * @Description
 * @Version 1.0
 */
@Component
@Aspect
@Order(1)
public class PersonProxy {
    @Before(value = "execution(* top.lingchen.spring5.aopanno.User.add(..))")
    public void before(){
        System.out.println("Person before ....");
    }

    @Pointcut(value = "execution(* top.lingchen.spring5.aopanno.Person.show(..))")
    public void pointDemo(){

    }
    @Before(value = "pointDemo()")
    public void beforePerson(){
        System.out.println("beforePerson ... ");
    }
    @After(value = "pointDemo()")
    public void afterPerson(){
        System.out.println("afterPerson ... ");
    }
    @AfterReturning(value = "pointDemo()")
    public void afterReturningPerson(){
        System.out.println("afterReturningPerson ... ");
    }
    @Around(value = "pointDemo()")
    public void aroundPerson(ProceedingJoinPoint point) throws Throwable{
        System.out.println("before aroundPerson .... ");
        point.proceed();
        System.out.println("after aroundPerson .... ");
    }
    @AfterThrowing(value = "pointDemo()")
    public void afterThrowing(){
        System.out.println("AfterThrowing Person ... ");
    }
}
